cmake_minimum_required(VERSION 3.18)
project(cuda_example LANGUAGES CXX CUDA)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置CUDA标准
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)

# 根据GPU架构设置，可根据实际情况调整
set(CMAKE_CUDA_ARCHITECTURES 86)

# 查找CUDA库
find_package(CUDA REQUIRED)

# 包含CUDA头文件目录
include_directories(${CUDA_INCLUDE_DIRS})

# 定义源文件
set(SOURCES
    main.cc
    cuda_fun.cu
)

# 定义头文件
set(HEADERS
    cuda_fun.h
)

# 创建可执行文件
add_executable(cuda_example ${SOURCES} ${HEADERS})

# 链接CUDA库
target_link_libraries(cuda_example ${CUDA_LIBRARIES})

# 设置CUDA编译选项
set_target_properties(cuda_example PROPERTIES
    CUDA_SEPARABLE_COMPILATION ON
    CUDA_RESOLVE_DEVICE_SYMBOLS ON
)
    